﻿using Inovout.Services;
using NHibernate.Criterion;
using System;

namespace Inovout.Security.Services
{
    public class EnumOperationService : RepositoryService<EnumOperation>, IEnumOperationService
    {
        public EnumOperation FindByEnum(Enum operation)
        {
            Type type = operation.GetType();
            int value = (int)(object)operation;
            EnumOperation enumOperation = base.Repository.Find(
                new ICriterion[]{  
                 Restrictions.Eq("OperationEnumType", type),
                Restrictions.Eq("OperationEnumValue", value)
                });           
            return enumOperation;

        }
    }
}
